<template>
    <div>
        <!-- 一，面包屑导航区域 -->
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>权限管理</el-breadcrumb-item>
            <el-breadcrumb-item>权限列表</el-breadcrumb-item>
        </el-breadcrumb>
        <!-- 二，卡片视图区域 -->
        <el-card>
            <el-table :data="rightsList" style="width: 100%" border stripe>
                <el-table-column type="index" label="#" width="50">
                </el-table-column>
                <el-table-column prop="authName" label="权限名称" width="180">
                </el-table-column>
                <el-table-column prop="path" label="路径" width="180">
                </el-table-column>
                <el-table-column prop="level" label="权限等级" width="180">
                    <template slot-scope="scope">
                        <el-tag v-if="scope.row.level === '0'">一级</el-tag>
                        <el-tag type="success" v-if="scope.row.level === '1'">二级</el-tag>
                        <el-tag type="warning" v-if="scope.row.level === '2'">三级</el-tag>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
    </div>
</template>
<!-- 权限管理组件。
1，新建权限组件，注册路由。布局开始，面包屑路径导航栏。卡片视图，发送权限列表请求getRightsList()，data定义好数组接收。接着渲染出来，用el-table ,
索引列type="index"，加边框border，带斑马纹stripe，隔行变色。美化等级：el-tag标签。按需导入使用，加template，slot-scope，等级显示v-if="scope.row.level === '0'"，

 -->
<script>
export default {
    data() {
        return {
            // 权限列表
            rightsList: [],
        }
    },
    created() {
        // 获取权限列表
        this.getRightsList()
    },
    methods: {
        // 请求获取权限列表
        async getRightsList() {
            const { data: res } = await this.$http.get('rights/list')
            console.log(res)
            if (res.meta.status !== 200) {
                return this.$message.error('获取失败')
            }
            this.rightsList = res.data
            console.log(this.rightsList)
        },
    },

}
</script>

<style lang="less" scoped>
</style>